﻿//AcademicPlanner - course registration planning web app.
//Copyright (C) 2009  Boubacar Diallo

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AcademicPlanner.Domain.Models;

namespace AcademicPlanner.Presentation.Views.Shared
{
	/// <summary>
	/// List of modes in which a AcademicTermsControl can be
	/// viewed.
	/// </summary>
	/// <since>1.0</since>
	public enum AcademicTermsControlMode
	{
		SELECT
	}

	/// <summary>
	/// AcademicTermsControlModel represents a model
	/// object for a <c>AcademicTermsControl</c> control.
	/// </summary>
	/// <since>1.0</since>
	public class AcademicTermsControlModel : ControlModel
	{
		/// <summary>
		/// The <c>Mode</c> to view this control in.
		/// </summary>
		/// <since>1.0</since>
		public AcademicTermsControlMode Mode { get; set; }

		/// <summary>
		/// Gets or sets the <c>AcademicTerm</c>s whose information
		/// is to be displayed.
		/// </summary>
		public IList<AcademicTerm> AcademicTerms { get; set; }

		/// <summary>
		/// Gets or sets the <c>AcademicTerm</c>s to mark as selected.
		/// </summary>
		/// <since>1.0</since>
		public IList<AcademicTerm> SelectedAcademicTerms { get; set; }

		/// <summary>
		/// Gets or sets the name of the field containing the list of <c>AcademicTerm</c>s selected.
		/// </summary>
		/// <since>1.0</since>
		public string SelectedAcademicTermsFieldName { get; set; }
	}


	/// <summary>
	/// AcademicTermsControl represents a control for displaying
	/// information about <c>AcademicTerm</c>s.
	/// </summary>
	/// <since>1.0</since>
	public partial class AcademicTermsControl : Control<AcademicTermsControlModel>
	{
		/// <summary>
		/// Handles the page load event for this control by initializing its
		/// properties.
		/// </summary>
		/// <param name="sender">The sender of the event.</param>
		/// <param name="e">The details of the event.</param>
		/// <since>1.0</since>
		protected void Page_Load(object sender, EventArgs e)
		{
			if (string.IsNullOrEmpty(Model.Id))
				Model.Id = "academicTermsControl";
		}
	}
}